#!/usr/bin/env python
# -*- coding: utf-8 -*-

import datetime
from src.database import (
    db,
    Model,
    SurrogatePK,
    ReferenceCol,
)


class Record(SurrogatePK, Model):
    __tablename__ = 'record'
    # Define a foreign key relationship to a User object
    user_id = ReferenceCol('user')
    category_id = ReferenceCol('category')
    title = db.Column(db.String(40), nullable=False)
    description = db.Column(db.String(300), nullable=False)
    brief = db.Column(db.String(100), nullable=False)
    img_before = db.Column(db.String(100), nullable=False)
    desc_before = db.Column(db.String(100), nullable=True)
    img_after = db.Column(db.String(100), nullable=False)
    desc_after = db.Column(db.String(100), nullable=True)
    tags = db.Column(db.String(100), nullable=True)
    view_count = db.Column(db.Integer, nullable=True)
    recommend_count = db.Column(db.Integer, nullable=True)
    is_show = db.Column(db.Integer, nullable=True, default=1)
    update_time = db.Column(db.DateTime, nullable=True, default=datetime.datetime.utcnow)
    create_time = db.Column(db.DateTime, nullable=True, default=datetime.datetime.utcnow)

    def __init__(self, **kwargs):
        db.Model.__init__(self, **kwargs)
